<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <title>宽度线</title>
  <link rel="icon" href="https://img.kaikeba.com/kkb_portal_icon.ico">
  <style>
    body {
      margin: 0;
      overflow: hidden;
    }

    #canvas {
      background-color: antiquewhite;
    }
  </style>
</head>

<body>
  <canvas id="canvas"></canvas>
  <script>
    const canvas = document.querySelector("#canvas");
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    //二维画笔
    const ctx = canvas.getContext('2d');

    ctx.lineWidth = 100
    // ctx.lineCap = 'butt'
    // ctx.lineCap = 'square'
    ctx.lineCap = 'round'

    ctx.lineJoin = 'miter'
    // ctx.lineJoin = 'round'
    // ctx.lineJoin = 'bevel' 

    ctx.miterLimit = 2

    ctx.setLineDash([30, 60, 90])

    ctx.lineDashOffset = 30

    ctx.beginPath()
    ctx.moveTo(700, 100)
    ctx.lineTo(300, 400)
    ctx.lineTo(700, 400)
    ctx.stroke()

    ctx.lineWidth = 3
    ctx.strokeStyle = 'yellow'
    ctx.beginPath()
    ctx.moveTo(700, 100)
    ctx.lineTo(300, 400)
    ctx.lineTo(700, 400)
    ctx.stroke()

  </script>
</body>

</html>